/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package game_shooter;

import framework.GameObjectSprite;
import framework.Key;
import framework.Map;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 *
 * @author marcossilvano
 */
public class Ship extends GameObjectSprite {
    private final Map map;
    
    public Ship(Image image, int frameWidth, int frameHeight) {
        super(image, frameWidth, frameHeight);
        setCurrentFrame(0);
        map = Map.getInstance();
    }

    public void update() {
        if (Key.LEFT_PRESSED) {
            setSpeedX(-1);
            
        } else
        if (Key.RIGHT_PRESSED) {
            setSpeedX(1);
           
        } else {
            setSpeedX(0);
        }
        
        setX(getX() + getSpeedX());
        setY(getY()-1);
        
        animate();
        
//        map.followsAndCollides(this);
    }

    public void paint(Graphics g) {
        drawSprite(g);
    }

    public void collided(GameObjectSprite collidedObject) {
    }
}
